package com.industrial.premu.service.impl;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.industrial.common.core.utils.DateUtils;
import com.industrial.common.core.utils.StringUtils;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.security.utils.SecurityUtils;
import com.industrial.premu.domain.PreMuCompanyInfo;
import com.industrial.premu.domain.PreMuCompanyTax;
import com.industrial.premu.domain.PreMuCountyImportTax;
import com.industrial.premu.domain.PreMuCountyTaxJl;
import com.industrial.premu.domain.sqsj.PreMuImportLog;
import com.industrial.premu.domain.sqsj.PreMuImportShuiwu;
import com.industrial.premu.domain.sqsj.PreMuImportTongji;
import com.industrial.premu.mapper.PreMuCompanyInfoMapper;
import com.industrial.premu.mapper.PreMuCountyImportTaxMapper;
import com.industrial.premu.mapper.PreMuCountyTaxJlMapper;
import com.industrial.premu.mapper.SysAreaMapper;
import com.industrial.premu.mapper.sqsj.PreMuImportLogMapper;
import com.industrial.premu.mapper.sqsj.PreMuImportShuiwuMapper;
import com.industrial.premu.service.IPreMuCountyImportTaxService;
import com.industrial.premu.util.ValidationUtil;
import com.industrial.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;


/**
 * 企业自已填写的税收Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-21
 */
@Service
public class PreMuCountyImportTaxServiceImpl implements IPreMuCountyImportTaxService
{
    @Autowired
    private PreMuCountyImportTaxMapper preMuCountyImportTaxMapper;

    @Autowired
    private PreMuCountyTaxJlMapper preMuCountyTaxJlMapper;

    @Autowired
    private PreMuImportShuiwuMapper preMuImportShuiwuMapper;

    @Autowired
    private PreMuCompanyInfoMapper preMuCompanyInfoMapper;

    @Autowired
    private PreMuImportLogMapper preMuImportLogMapper;

    @Autowired
    private SysAreaMapper sysAreaMapper;
    private static final String pattern = "^\\d+(\\.\\d+)?$";

    private int BATCH_SIZE = 100;

    /**
     * 查询企业自已填写的税收
     *
     * @param baseId 企业自已填写的税收主键
     * @return 企业自已填写的税收
     */
    @Override
    public PreMuCountyImportTax selectPreMuCountyImportTaxByBaseId(String baseId)
    {
        return preMuCountyImportTaxMapper.selectPreMuCountyImportTaxByBaseId(baseId);
    }

    /**
     * 查询企业自已填写的税收列表
     *
     * @param preMuCountyImportTax 企业自已填写的税收
     * @return 企业自已填写的税收
     */
    @Override
    public List<PreMuCountyImportTax> selectPreMuCountyImportTaxList(PreMuCountyImportTax preMuCountyImportTax)
    {
        return preMuCountyImportTaxMapper.selectPreMuCountyImportTaxList(preMuCountyImportTax);
    }

    /**
     * 新增企业自已填写的税收
     *
     * @param preMuCountyImportTax 企业自已填写的税收
     * @return 结果
     */
    @Override
    public int insertPreMuCountyImportTax(PreMuCountyImportTax preMuCountyImportTax)
    {
        return preMuCountyImportTaxMapper.insertPreMuCountyImportTax(preMuCountyImportTax);
    }

    /**
     * 修改企业自已填写的税收
     *
     * @param preMuCountyImportTax 企业自已填写的税收
     * @return 结果
     */
    @Override
    public int updatePreMuCountyImportTax(PreMuCountyImportTax preMuCountyImportTax)
    {
        return preMuCountyImportTaxMapper.updatePreMuCountyImportTax(preMuCountyImportTax);
    }

    /**
     * 批量删除企业自已填写的税收
     *
     * @param baseIds 需要删除的企业自已填写的税收主键
     * @return 结果
     */
    @Override
    public int deletePreMuCountyImportTaxByBaseIds(String[] baseIds)
    {
        return preMuCountyImportTaxMapper.deletePreMuCountyImportTaxByBaseIds(baseIds);
    }

    /**
     * 删除企业自已填写的税收信息
     *
     * @param baseId 企业自已填写的税收主键
     * @return 结果
     */
    @Override
    public int deletePreMuCountyImportTaxByBaseId(String baseId)
    {
        return preMuCountyImportTaxMapper.deletePreMuCountyImportTaxByBaseId(baseId);
    }




    /**
     * 导入企业的数据
     *
     * @param file
     * @param companyType
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AjaxResult importCompanyTaxData(MultipartFile file, String companyType,String years) {
        try{
            ExcelUtil<PreMuImportShuiwu> util = new ExcelUtil<PreMuImportShuiwu>(PreMuImportShuiwu.class);
            List<PreMuImportShuiwu> preMuImportShuiwus = util.importExcel(file.getInputStream());

            if(preMuImportShuiwus == null || preMuImportShuiwus.isEmpty()){
                return AjaxResult.warn("没有找到需要导入的数据");
            }
            String district = SecurityUtils.getLoginUser().getSysUser().getDistrict();
            List<String> usccList = new ArrayList<String>();
            List<PreMuImportShuiwu> realList = new ArrayList<PreMuImportShuiwu>();

            List<PreMuImportShuiwu> addImportList = new ArrayList<PreMuImportShuiwu>();
            List<PreMuImportShuiwu> updateImportList = new ArrayList<PreMuImportShuiwu>();


            //企业名称为空的错误数据量
            int companyNameBlankCount = 0;
            //值为空的错误量
            int valueErrorCount = 0;
            int valueZeroCount = 0;
            int successNum = 0;
            int failureNum = 0;

            for(PreMuImportShuiwu data : preMuImportShuiwus){

                if("2".equals(companyType)){
                    data.setCompanyType("2");
                }

                if (data.getUscc() != null && !"".equals(data.getUscc())) {
                    usccList.add(data.getUscc().trim());
                    realList.add(data);
                }
            }

            long count = usccList.stream().distinct().count();
            boolean isRepeat = count < usccList.size();
            if (isRepeat) {
                return AjaxResult.error("有重复统一社会信用代码，请检查导入数据！");
            }
            //查询已存在的数据
            List<String> mcImportExistList =  preMuCountyImportTaxMapper.getImportShuiwuExistList(years,usccList);
            ValidationUtil.validate(realList);

            for (int i = 0; i < preMuImportShuiwus.size(); i++) {
                PreMuImportShuiwu mcImportShuiwuDO = preMuImportShuiwus.get(i);
                mcImportShuiwuDO.setYear(years);
                String uscc = mcImportShuiwuDO.getUscc();
                if (uscc == null || "".equals(uscc) || years == null || "".equals(years)) {
                    continue;
                } else {
                    uscc = uscc.trim();
                }

                if(StringUtils.isBlank(mcImportShuiwuDO.getCompanyName())){
                    companyNameBlankCount++;
                    continue;
                }

                if("1".equals(companyType)){
                    if(StringUtils.isBlank(mcImportShuiwuDO.getMainIncome()) || !Pattern.matches(pattern, mcImportShuiwuDO.getMainIncome()) ||
                            StringUtils.isBlank(mcImportShuiwuDO.getRdFunds()) || !Pattern.matches(pattern, mcImportShuiwuDO.getRdFunds()) ||
                            StringUtils.isBlank(mcImportShuiwuDO.getActualTax()) || !Pattern.matches(pattern, mcImportShuiwuDO.getActualTax())){
                        valueErrorCount++;
                        continue;
                    }

                    if(StringUtils.isBlank(mcImportShuiwuDO.getActualTax()) || StringUtils.isBlank(mcImportShuiwuDO.getRdFunds())){
                        failureNum++;
                        continue;
                    }
                }else{
                    if(StringUtils.isBlank(mcImportShuiwuDO.getMainIncome()) || !Pattern.matches(pattern, mcImportShuiwuDO.getMainIncome()) ||
                            StringUtils.isBlank(mcImportShuiwuDO.getActualTax()) || !Pattern.matches(pattern, mcImportShuiwuDO.getActualTax())){
                        valueErrorCount++;
                        continue;
                    }

                    if(StringUtils.isBlank(mcImportShuiwuDO.getActualTax())){
                        failureNum++;
                        continue;
                    }
                }
                BigDecimal mainIncomeBig = StringUtils.isBlank(mcImportShuiwuDO.getMainIncome())? BigDecimal.ZERO : new BigDecimal(mcImportShuiwuDO.getMainIncome());
                BigDecimal rdFundsBig = StringUtils.isBlank(mcImportShuiwuDO.getRdFunds())? BigDecimal.ZERO : new BigDecimal(mcImportShuiwuDO.getRdFunds());
                BigDecimal actualTaxBig = StringUtils.isBlank(mcImportShuiwuDO.getActualTax())? BigDecimal.ZERO : new BigDecimal(mcImportShuiwuDO.getActualTax());

                if("1".equals(companyType)){
                    if(mainIncomeBig.compareTo(BigDecimal.ZERO) < 1 || rdFundsBig.compareTo(BigDecimal.ZERO) < 1 || actualTaxBig.compareTo(BigDecimal.ZERO) < 1){
                        valueZeroCount++;
                        continue;
                    }
                }else{
                    if(mainIncomeBig.compareTo(BigDecimal.ZERO) < 1 || actualTaxBig.compareTo(BigDecimal.ZERO) < 1){
                        valueZeroCount++;
                        continue;
                    }
                }

                BigDecimal actualTax = new BigDecimal("0.0000");
                if (mcImportShuiwuDO.getActualTax() == null) {
                    mcImportShuiwuDO.setActualTax(actualTax.toString());
                }
                BigDecimal bigDecimal = new BigDecimal(mcImportShuiwuDO.getActualTax());

                if (bigDecimal.compareTo(actualTax) < 0) {
                    mcImportShuiwuDO.setActualTax(actualTax.toString());
                }

                if(StringUtils.isNotBlank(mcImportShuiwuDO.getMainIncome())){
                    //保留两位小数
                    BigDecimal mainIncomeNumeric = new BigDecimal(mcImportShuiwuDO.getMainIncome()).setScale(2, RoundingMode.HALF_UP);
                    mcImportShuiwuDO.setMainIncome(mainIncomeNumeric.toString());
                }

                if(StringUtils.isNotBlank(mcImportShuiwuDO.getActualTax())){
                    //保留两位小数
                    BigDecimal actualTaxNumeric = new BigDecimal(mcImportShuiwuDO.getActualTax()).setScale(2, RoundingMode.HALF_UP);
                    mcImportShuiwuDO.setActualTax(actualTaxNumeric.toString());
                }

                if (mcImportExistList.contains(uscc)) {
                    mcImportShuiwuDO.setUpdateDate(DateUtils.getNowDate());
                    mcImportShuiwuDO.setUpdateBy(SecurityUtils.getUserId());
                    mcImportShuiwuDO.setDelFlag("0");
                    updateImportList.add(mcImportShuiwuDO);
                } else {
                    mcImportShuiwuDO.setId(UUID.randomUUID().toString().replace("-", ""));
                    mcImportShuiwuDO.setDelFlag("0");
                    mcImportShuiwuDO.setYear(years);
                    mcImportShuiwuDO.setCounty(district);
                    mcImportShuiwuDO.setCreateDate(DateUtils.getNowDate());
                    mcImportShuiwuDO.setCreateBy(SecurityUtils.getUserId());
                    addImportList.add(mcImportShuiwuDO);
                }

                if (addImportList != null && addImportList.size() >= BATCH_SIZE) {

                    int importNum = preMuCountyImportTaxMapper.batchSave(addImportList);
                    successNum += importNum;
                    addImportList.clear();
                }
                if (updateImportList != null && updateImportList.size() >= BATCH_SIZE) {

                    int importNum = preMuCountyImportTaxMapper.batchUpdateByUscc(years, updateImportList);
                    successNum += importNum;
                    updateImportList.clear();
                }
            }
            if (addImportList != null && !addImportList.isEmpty()) {

                int importNum = preMuCountyImportTaxMapper.batchSave(addImportList);
                successNum += importNum;
                addImportList.clear();
            }
            if (updateImportList != null && !updateImportList.isEmpty()) {

                int importNum = preMuCountyImportTaxMapper.batchUpdateByUscc(years, updateImportList);
                successNum += importNum;
                updateImportList.clear();
            }
            if(valueZeroCount > 0 || failureNum > 0 || companyNameBlankCount > 0){
                return AjaxResult.warn("导入失败，存在错误数据");
            }


            //查询记录表中是否存在当前年份区县的数据
            int counts = preMuCountyTaxJlMapper.selectPreMuCountyTaxJlByCountyAndYears(years,district);
            if(counts > 0){
                preMuCountyTaxJlMapper.deletePreMuCountyTaxJlByYearsAndCounty(years,district);
            }
            PreMuCountyTaxJl preMuCountyTaxJl = new PreMuCountyTaxJl();
            preMuCountyTaxJl.setBaseId(IdUtil.simpleUUID());
            preMuCountyTaxJl.setCounty(district);
            preMuCountyTaxJl.setYears(years);
            preMuCountyTaxJl.setCountyName(sysAreaMapper.selectAreaNameByCode(district));
            preMuCountyTaxJl.setBaseCreateTime(DateUtils.getNowDate());
            preMuCountyTaxJl.setBaseCreateBy(SecurityUtils.getUserId());

            preMuCountyTaxJlMapper.insertPreMuCountyTaxJl(preMuCountyTaxJl);
            return AjaxResult.success("导入成功");
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.warn("导入失败");
        }
    }

    /**
     * 删除当前区县导入的数据
     *
     * @param year     年份
     * @param district 区县代码
     * @return 结果
     */
    @Override
    public AjaxResult deleteCurrentCountyImportData(String year, String district,String companyType) {
        int i = preMuCountyImportTaxMapper.deletePreMuCountyImportTaxByYearAndCounty(year, district, companyType);
        return i > 0 ? AjaxResult.success("删除成功") : AjaxResult.warn("删除失败");
    }


    /**
     * 省级审核区县
     *
     * @param county 行政区代码
     * @param years 年份
     * @return 结果
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AjaxResult provinceCheck(String county, String years) {
        //修改记录的状态
        PreMuCountyTaxJl preMuCountyTaxJl = new PreMuCountyTaxJl();
        preMuCountyTaxJl.setYears(years);
        preMuCountyTaxJl.setCounty(county);
        preMuCountyTaxJl.setStatus("1");
        preMuCountyTaxJlMapper.updatePreMuCountyTaxJlStatusByYearsAndCounty(preMuCountyTaxJl);

        //查询当前年份区县的企业信息
        PreMuCountyImportTax preMuCountyImportTaxQuery = new PreMuCountyImportTax();
        preMuCountyImportTaxQuery.setCounty(county);
        preMuCountyImportTaxQuery.setYears(years);
        preMuCountyImportTaxQuery.setDelFlag("0");
        List<PreMuImportShuiwu> preMuImportShuiwus = preMuCountyImportTaxMapper.selectPreMuCountyImportTaxListNew(preMuCountyImportTaxQuery);

        if (preMuImportShuiwus == null || preMuImportShuiwus.isEmpty()) {
            return AjaxResult.warn("没有找到需要处理的数据");
        }

        //Uscc集合
        List<String> usccList = preMuImportShuiwus.stream().map(PreMuImportShuiwu::getUscc).collect(Collectors.toList());
        List<PreMuCompanyInfo> preMuCompanyInfos = preMuCompanyInfoMapper.selectCompanyTypeByUsccArgsAndYears(usccList, years);
        if (preMuCompanyInfos == null || preMuCompanyInfos.isEmpty()) {
            return AjaxResult.warn("没有查询到企业信息");
        }

        //Uscc与企业类型的映射
        Map<String, String> usccToCompanyTypeMapping = preMuCompanyInfos.stream().collect(Collectors.toMap(k -> k.getUscc(), v -> v.getCompanyType()));


        //查询已经在税务表中存的数据
        List<PreMuImportShuiwu> importShuiWuList = preMuImportShuiwuMapper.selectPreMuImportShuiwuInfoByUsccsAndYears(usccList, years);

        List<PreMuImportShuiwu> insertDataList = new ArrayList<>();
        List<PreMuImportShuiwu> updateDataList = new ArrayList<>();
        int gsCount = 0;
        int gxCount = 0;

        if (importShuiWuList != null && !importShuiWuList.isEmpty()) {
            Map<String, String> oldDataMap = importShuiWuList.stream().collect(Collectors.toMap(k -> k.getUscc(), v -> v.getId()));
            for (PreMuImportShuiwu temp : preMuImportShuiwus) {
                if (oldDataMap.containsKey(temp.getUscc())) {
                    //这个里面是需要更新的数据
                    PreMuImportShuiwu preMuImportShuiwu = new PreMuImportShuiwu();
                    BeanUtil.copyProperties(temp, preMuImportShuiwu);
                    preMuImportShuiwu.setId(oldDataMap.get(temp.getUscc()));
                    preMuImportShuiwu.setUpdateDate(DateUtils.getNowDate());
                    preMuImportShuiwu.setDelFlag("0");
                    preMuImportShuiwu.setUpdateBy(SecurityUtils.getUserId());
                    updateDataList.add(preMuImportShuiwu);
                } else {
                    String companType = usccToCompanyTypeMapping.get(temp.getUscc());
                    if (StringUtils.equals(companType, "1")) {
                        gsCount++;
                    } else if (StringUtils.equals(companType, "2")) {
                        gxCount++;
                    } else {
                        throw new RuntimeException("非法企业类型");
                    }
                    //这个里面是需要新增的数据
                    PreMuImportShuiwu preMuImportShuiwu = new PreMuImportShuiwu();
                    BeanUtil.copyProperties(temp, preMuImportShuiwu);
                    preMuImportShuiwu.setId(IdUtil.simpleUUID());
                    preMuImportShuiwu.setYear(temp.getYear());
                    preMuImportShuiwu.setDelFlag("0");
                    preMuImportShuiwu.setCreateBy(SecurityUtils.getUserId());
                    preMuImportShuiwu.setCreateDate(DateUtils.getNowDate());
                    insertDataList.add(preMuImportShuiwu);
                }
                if (updateDataList.size() > 100) {
                    preMuImportShuiwuMapper.batchUpdateById(updateDataList);
                    updateDataList.clear();
                    System.gc();
                }

                if (insertDataList.size() > 100) {
                    preMuImportShuiwuMapper.batchInsert(insertDataList);
                    insertDataList.clear();
                    System.gc();
                }
            }
            if (!updateDataList.isEmpty()) {
                preMuImportShuiwuMapper.batchUpdateById(updateDataList);
                updateDataList.clear();
                System.gc();
            }

            if (!insertDataList.isEmpty()) {
                preMuImportShuiwuMapper.batchInsert(insertDataList);
                insertDataList.clear();
                System.gc();
            }
        } else {
            //如果importShuiWuList等于空，批量申核后将所有的数据全部插入
            for (PreMuImportShuiwu temp : preMuImportShuiwus) {

                String companType = usccToCompanyTypeMapping.get(temp.getUscc());
                if (StringUtils.equals(companType, "1")) {
                    gsCount++;
                } else if (StringUtils.equals(companType, "2")) {
                    gxCount++;
                } else {
                    throw new RuntimeException("非法企业类型");
                }

                //不存在则插入
                PreMuImportShuiwu preMuImportShuiwu = new PreMuImportShuiwu();
                BeanUtil.copyProperties(temp, preMuImportShuiwu);
                preMuImportShuiwu.setId(IdUtil.simpleUUID());
                preMuImportShuiwu.setYear(temp.getYear());
                preMuImportShuiwu.setCreateBy(SecurityUtils.getUserId());
                preMuImportShuiwu.setCreateDate(DateUtils.getNowDate());
                preMuImportShuiwu.setDelFlag("0");
                insertDataList.add(preMuImportShuiwu);

                if (insertDataList.size() > 100) {
                    insertDataList.clear();
                    System.gc();
                }
            }
            if (!insertDataList.isEmpty()) {
                preMuImportShuiwuMapper.batchInsert(insertDataList);
                insertDataList.clear();
                System.gc();
            }
        }


        //省
        String province = StringUtils.left(county,2) + "0000";
        //市
        String city = StringUtils.left(county,4) + "00";
        //区
        String district = county;

        //存在规上企业
        if (gsCount > 0) {
            PreMuImportLog preMuImportLog = preMuImportLogMapper.selectCurrentDistrictDeptInfo(province, city, district, years, "04");
            if (preMuImportLog != null) {
                Long deptCodeSum = preMuImportLog.getDeptCodeSum();
                PreMuImportLog preMuImportLogUpdateParams = new PreMuImportLog();
                preMuImportLogUpdateParams.setDeptCodeSum(deptCodeSum + gsCount);
                preMuImportLogUpdateParams.setId(preMuImportLog.getId());
                preMuImportLogUpdateParams.setUpdateDate(DateUtils.getNowDate());
                preMuImportLogUpdateParams.setUpdateBy(SecurityUtils.getUserId());
                preMuImportLogMapper.updatePreMuImportLog(preMuImportLogUpdateParams);
            } else {
                PreMuImportLog preMuImportLogInsertParams = new PreMuImportLog();
                preMuImportLogInsertParams.setDeptCodeSum(Long.valueOf(gsCount));
                preMuImportLogInsertParams.setId(IdUtil.simpleUUID());
                preMuImportLogInsertParams.setUpdateDate(DateUtils.getNowDate());
                preMuImportLogInsertParams.setUpdateBy(SecurityUtils.getUserId());
                preMuImportLogInsertParams.setCreateDate(DateUtils.getNowDate());
                preMuImportLogInsertParams.setCreateBy(SecurityUtils.getUserId());
                preMuImportLogInsertParams.setDeptCode("04");
                preMuImportLogInsertParams.setYear(years);
                preMuImportLogInsertParams.setDelFlag("0");
                preMuImportLogInsertParams.setProvince(province);
                preMuImportLogInsertParams.setCity(city);
                preMuImportLogInsertParams.setCounty(district);
                preMuImportLogMapper.insertPreMuImportLog(preMuImportLogInsertParams);
            }
        }


        //存在规下企业
        if (gxCount > 0) {
            PreMuImportLog preMuImportLog = preMuImportLogMapper.selectCurrentDistrictDeptInfo(province, city, district, years, "09");
            if (preMuImportLog != null) {
                Long deptCodeSum = preMuImportLog.getDeptCodeSum();
                PreMuImportLog preMuImportLogUpdateParams = new PreMuImportLog();
                preMuImportLogUpdateParams.setDeptCodeSum(deptCodeSum + gxCount);
                preMuImportLogUpdateParams.setId(preMuImportLog.getId());
                preMuImportLogUpdateParams.setUpdateDate(DateUtils.getNowDate());
                preMuImportLogUpdateParams.setUpdateBy(SecurityUtils.getUserId());
                preMuImportLogMapper.updatePreMuImportLog(preMuImportLogUpdateParams);
            } else {
                PreMuImportLog preMuImportLogInsertParams = new PreMuImportLog();
                preMuImportLogInsertParams.setDeptCodeSum(Long.valueOf(gxCount));
                preMuImportLogInsertParams.setId(IdUtil.simpleUUID());
                preMuImportLogInsertParams.setUpdateDate(DateUtils.getNowDate());
                preMuImportLogInsertParams.setUpdateBy(SecurityUtils.getUserId());
                preMuImportLogInsertParams.setCreateDate(DateUtils.getNowDate());
                preMuImportLogInsertParams.setCreateBy(SecurityUtils.getUserId());
                preMuImportLogInsertParams.setDeptCode("09");
                preMuImportLogInsertParams.setYear(years);
                preMuImportLogInsertParams.setDelFlag("0");
                preMuImportLogInsertParams.setProvince(province);
                preMuImportLogInsertParams.setCity(city);
                preMuImportLogInsertParams.setCounty(district);
                preMuImportLogMapper.insertPreMuImportLog(preMuImportLogInsertParams);
            }
        }
            StringBuilder msg = new StringBuilder();
            String s = sysAreaMapper.selectAreaNameByCode(county);
            msg.append(String.format("【%s】导入的数据已生效", s));
            return AjaxResult.success(msg.toString());
    }
}

